/*
 * Copyright (C) 2016 Facishare Technology Co., Ltd. All Rights Reserved.
 */
package com.wlh.animation;

import java.util.ArrayList;
import java.util.List;

import com.wlh.animation.basic.BasicAnimationAct;
import com.wlh.animation.demo.BaseDemoListAct;
import com.wlh.animation.ipctest.IPCTestAct;
import com.wlh.animation.others.ClipChildrenTestAct;
import com.wlh.animation.overdraw.OverDrawAct;
import com.wlh.animation.property.PropertyAnimationAct;
import com.wlh.animation.userviews.UserViewsMenuAct;
import com.wlh.animation.vector.VectorAnimationAct;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null)
                        .show();
            }
        });
        List<String> menuList = new ArrayList<>();
        menuList.add("基础动画");
        menuList.add("属性动画");
        menuList.add("矢量动画");
        menuList.add("动画特效");
        menuList.add("Touch事件分发");
        menuList.add("ScrollView嵌套EditView'");
        menuList.add("IPC机制测试");
        menuList.add("过度绘制");
        menuList.add("clipChildren");
        menuList.add("自定义View");

        ListView listView = (ListView) findViewById(R.id.list);
        listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuList));
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        startActivity(new Intent(MainActivity.this, BasicAnimationAct.class));
                        break;
                    case 1:
                        startActivity(new Intent(MainActivity.this, PropertyAnimationAct.class));
                        break;
                    case 2:
                        startActivity(new Intent(MainActivity.this, VectorAnimationAct.class));
                        break;
                    case 3:
                        startActivity(new Intent(MainActivity.this, BaseDemoListAct.class));
                        break;
                    case 4:
                        startActivity(new Intent(MainActivity.this, TouchDemoAct.class));
                        break;
                    case 5:
                        startActivity(new Intent(MainActivity.this, ScrollEditViewAct.class));
                        break;
                    case 6:
                        startActivity(new Intent(MainActivity.this, IPCTestAct.class));
                        break;
                    case 7:
                        startActivity(new Intent(MainActivity.this, OverDrawAct.class));
                    case 8:
                        startActivity(new Intent(MainActivity.this, ClipChildrenTestAct.class));
                    case 9:
                        startActivity(new Intent(MainActivity.this, UserViewsMenuAct.class));
                }
            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}
